#include "stdafx.h"
#include "CppUnitTest.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace UnitTest_Feedback
{		
	TEST_CLASS(UnitTest1)
	{
	public:
		
		TEST_METHOD(writeOutExecutionFb)
		{
			// test feedback message when Add is successfully executed
			Feedback* fb = new Feedback();
			fb->setIsValid(true);
			fb->setSucceedType(SucceedAdd);
			std::string result1 = fb->writeOutExecutionFb();
			std::string expected1 = "Execution succeeds, the event has been added\n";
			Assert::AreEqual(expected1, result1);

			// test feedback message when Delete is successfully executed
			Feedback* fb1 = new Feedback();
			fb->setIsValid(true);
			fb->setSucceedType(SucceedDelete);
			std::string result2 = fb->writeOutExecutionFb();
			std::string expected2 = "Execution succeeds, the event has been deleted\n";
			Assert::AreEqual(expected2, result2);

			// test feedback message when Update is successfully executed
			Feedback* fb2 = new Feedback();
			fb->setIsValid(true);
			fb->setSucceedType(SucceedUpdate);
			std::string result3 = fb->writeOutExecutionFb();
			std::string expected3 = "Execution succeeds, the event has been updated\n";
			Assert::AreEqual(expected3, result3);

			// test feedback message when Read is successfully executed
			Feedback* fb3 = new Feedback();
			fb->setIsValid(true);
			fb->setSucceedType(SuccedRead);
			std::string result4 = fb->writeOutExecutionFb();
			std::string expected4 = "Execution succeeds, the calendar has been read\n";
			Assert::AreEqual(expected4, result4);

			// test feedback message when Search is successfully executed
			Feedback* fb4 = new Feedback();
			fb->setIsValid(true);
			fb->setSucceedType(SucceedSearch);
			std::string result5 = fb->writeOutExecutionFb();
			std::string expected5 = "Execution succeeds, the event has been found\n";
			Assert::AreEqual(expected5, result5);

			// test feedback message when Mark is successfully executed
			Feedback* fb5 = new Feedback();
			fb->setIsValid(true);
			fb->setSucceedType(SucceedMark);
			std::string result6 = fb->writeOutExecutionFb();
			std::string expected6 = "Execution succeeds, the event has been marked\n";
			Assert::AreEqual(expected6, result6);

			// test feedback message when Display is successfully executed
			Feedback* fb6 = new Feedback();
			fb->setIsValid(true);
			fb->setSucceedType(SucceedDisplay);
			std::string result7 = fb->writeOutExecutionFb();
			std::string expected7 = "Execution succeeds, the event has been displayed\n";
			Assert::AreEqual(expected7, result7);

			// test feedback message when changing Status is successfully executed
			Feedback* fb7 = new Feedback();
			fb->setIsValid(true);
			fb->setSucceedType(SucceedStatus);
			std::string result8 = fb->writeOutExecutionFb();
			std::string expected8 = "Execution succeeds, the event's status has been updated\n";
			Assert::AreEqual(expected8, result8);

			// test feedback message when Undo is successfully executed
			Feedback* fb8 = new Feedback();
			fb->setIsValid(true);
			fb->setSucceedType(SucceedUndo);
			std::string result9 = fb->writeOutExecutionFb();
			std::string expected9 = "Execution succeeds, undo the last available command\n";
			Assert::AreEqual(expected9, result9);

			// test feedback message when there is Format Error 
			Feedback* fb9 = new Feedback();
			fb->setIsValid(false);
			fb->setErrorType(ErrorFormat);
			std::string result10 = fb->writeOutExecutionFb();
			std::string expected10 = "Execution fails, instruction is invalid\n";
			Assert::AreEqual(expected10, result10);

			// test feedback message when the target is Not Found
			Feedback* fb10 = new Feedback();
			fb->setIsValid(false);
			fb->setErrorType(ErrorNotFound);
			std::string result11 = fb->writeOutExecutionFb();
			std::string expected11 = "Execution fails, target is not found\n";
			Assert::AreEqual(expected11, result11);

			// test feedback message when there is no available commands to undo
			Feedback* fb11 = new Feedback();
			fb->setIsValid(false);
			fb->setErrorType(ErrorUndo);
			std::string result12 = fb->writeOutExecutionFb();
			std::string expected12 = "Execution fails, no available commands to undo\n";
			Assert::AreEqual(expected12, result12);

			// test feedback message when date and time invalid
			Feedback* fb12 = new Feedback();
			fb->setIsValid(false);
			fb->setErrorType(ErrorWrongTime);
			std::string result13 = fb->writeOutExecutionFb();
			std::string expected13 = "Execution fails, date or time is invalid\n";
			Assert::AreEqual(expected13, result13);		

			// test feedback message when parser is Confused
			Feedback* fb13 = new Feedback();
			fb->setIsValid(false);
			fb->setErrorType(ErrorConfuse);
			std::string result14 = fb->writeOutExecutionFb();
			std::string expected14 = "Execution fails, parser is confused about what is the time and date, please use t[ ] to mark the location of time and date. e.g t[12:00 tmr] \n";
			Assert::AreEqual(expected14, result14);		
		}
	};
}